package com.example.service;

import com.example.entity.FlClient;
import com.example.mapper.FLClientMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

@Service
public class FLClientService {

    @Resource
    private FLClientMapper flClientMapper;

    /**
     * 新增客户端
     */
    public void add(FlClient flClient) {
        flClient.setLastActive(new Timestamp(new Date().getTime()));
        flClientMapper.insert(flClient);
    }

    /**
     * 根据客户端ID删除客户端
     */
    public void deleteByClientId(String clientId) {
        flClientMapper.deleteByClientId(clientId);
    }

    /**
     * 更新客户端信息
     */
    public void update(FlClient flClient) {
        flClientMapper.update(flClient);
    }

    /**
     * 根据客户端ID查询客户端
     */
    public FlClient getByClientIdAndTaskId(String clientId, String taskid) {
        return flClientMapper.selectByClientIdAndTaskId(clientId, taskid);
    }

    /**
     * 查询所有客户端
     */
    public List<FlClient> getAll(FlClient flClient) {
        return flClientMapper.selectAll(flClient);
    }
}